package com.application.lucky.widget.time;

import java.util.ArrayList;

/**
 * Created by santa on 16/7/19.
 */
public class SelectorContanst {
    private static SelectorContanst instance = null;
    public static ArrayList<String> MONTHS = null;
    public static ArrayList<String> YEARS = null;
    public static ArrayList<String> DAYS = null;
    public static ArrayList<String> HOURS = null;
    public static ArrayList<String> MINS = null;
    public static ArrayList<String> SECS = null;

    private static String addZero(int i) {
        return i < 10 ? ("0" + i) : i + "";
    }


    public static ArrayList<String> getMonths() {
        if (null == MONTHS) {
            synchronized (SelectorContanst.class) {
                MONTHS = new ArrayList<>();
                for (int i = 1; i <= 12; i++) {
                    MONTHS.add(addZero(i) + "月");
                }
            }
        }
        return MONTHS;
    }


    public static ArrayList<String> getYears() {
        if (null == YEARS) {
            synchronized (SelectorContanst.class) {
                YEARS = new ArrayList<>();
                for (int i = 1900; i <= 3000; i++) {
                    YEARS.add(addZero(i) + "年");
                }
            }
        }
        return YEARS;
    }

    public static ArrayList<String> getYears(int startYear, int endYear) {
        if (null == YEARS) {
            synchronized (SelectorContanst.class) {
                YEARS = new ArrayList<>();
                for (int i = startYear; i <= endYear; i++) {
                    YEARS.add(addZero(i) + "年");
                }
            }
        }
        return YEARS;
    }


    public static ArrayList<String> getDays() {
        if (null == DAYS) {
            synchronized (SelectorContanst.class) {
                DAYS = new ArrayList<>();
                for (int i = 1; i <= 31; i++) {
                    DAYS.add(addZero(i) + "日");
                }
            }
        }
        return DAYS;
    }


    public static ArrayList<String> getHours() {
        if (null == HOURS) {
            synchronized (SelectorContanst.class) {
                HOURS = new ArrayList<>();
                for (int i = 0; i <= 23; i++) {
                    HOURS.add(addZero(i) + "时");
                }
            }
        }
        return HOURS;
    }


    public static ArrayList<String> getMins() {
        if (null == MINS) {
            synchronized (SelectorContanst.class) {
                MINS = new ArrayList<>();
                for (int i = 0; i <= 59; i++) {
                    MINS.add(addZero(i) + "分");
                }
            }
        }
        return MINS;
    }


    public static ArrayList<String> getSecs() {
        if (null == SECS) {
            synchronized (SelectorContanst.class) {
                SECS = new ArrayList<>();
                for (int i = 0; i <= 59; i++) {
                    SECS.add(addZero(i) + "秒");
                }
            }
        }
        return SECS;
    }
}
